<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/candidates/tmpl/mycv.php
 ^ 
 * Description: template view my cv
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');
   global $mainframe;
  $document =& JFactory::getDocument();

  /*$document->addScript( 'components/com_wrecruit/js/jquery-1.7.2.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery-ui.min.js' );
  $document->addScript( 'components/com_wrecruit/js/jquery.uniform.js' );
  $document->addScript( 'components/com_wrecruit/js/scripts.js' );*/
  $document->addScript( 'components/com_wrecruit/js/popup.js' );
  $document->addStyleSheet('components/com_wrecruit/css/popup.css');
  $document->addStyleSheet('components/com_wrecruit/css/chosen/chosen.css');
  $candidate = $this->getModel('wrecruit', 'WRecruitModel');
  $user	=& JFactory::getUser();
  if(isset($user->id) && $user->id == 0 || $user->id == ''){
	   $app =& JFactory::getApplication(); 
	   $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );
	  return;
  }else{
  	$candidateObj = $candidate->getAllCandidatesInfor($user->id);
	if( !$candidateObj ){
		$app =& JFactory::getApplication(); 
       //add a message to the message queue
        $app->enqueueMessage( JText::_( 'Please <a href="index.php?option=com_users&view=login">Login</a>' ), 'Login access' );

		return;
	}
	
  }
  $com_base = "components/com_wrecruit/";
  //Registric resume access
  if(!$candidate->checkAuticationResume($user->id,JRequest::getVar('id'))){
	  $session = &JFactory::getSession();
	  $msg = $session->get('job_msg');
	  echo $msg;
	  return;
  }
?>


				<div class="box-list-job">
					<div class="job-seeker-panel">
						<?php include('components/com_wrecruit/views/candidates/tmpl/menuLeft.php');?>
					</div>
					
					<div class="job-seeker-right">
						<div class="head-title">
						<h2>View CV</h2>
						</div>
						<?php
						$styles = "
							.cv_title_label{
								color:#000;
								font-weight:bold;
							}
						";
						$document->addStyleDeclaration($styles, 'text/css');
						if ($data = $candidate->getCvViewInfoById(JRequest::getVar('id')) ) {
						      if($data->RESUME_TYPE!=0){ 
									echo "Does not valide cv type!";
						       }else{	
						?>
                                    <div class="divwrapp-mycv">
									
										<table width="100%">
											<tbody>
												<tr>
													<td width="20%"><label class="cv_title_label">Cv Title: </label></td>
													<td><?php echo $data->APPLICATION_TITLE; ?></td>
													<td rowspan="6" >
													  <div id="pic-pro" style="text-align:right; float:right; margin:0;">
														<img  height="100" width="100" src="<?php echo JURI::base();?>/wrecruitdata/photo/<?php echo $candidateObj->photo; ?>" 
						alt="<?php echo $candidateObj->firstname." ".$candidateObj->lastname;?>">
													  </div>
													</td>
												</tr>
												<tr>
													<td><label class="cv_title_label">Name: </label></td>
													<td><span style="font-weight:bold;"><?php echo $data->firstname.' '.$data->lastname; ?><span></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Sex: </label></td>
													<td><?php 
															echo ($data->gender_id=1)?'Male':'Female';
														?></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Date of birth: </label></td>
													<td><?php echo $data->date_of_birth; ?></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Highest Education: </label></td>
													<td><?php echo $data->education_name; ?></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Career Domain: </label></td>
													<td><?php  echo $data->candidate_career; ?></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Expected salary: </label></td>
													<td><?php echo $data->SALARY; ?></td>
													
												</tr>
												<tr>
													<td><label class="cv_title_label">Last updated: </label></td>
													<td><?php echo $data->MODIFIED_DATE; ?></td>
													<td><!--<a style ="float:right;" href="#">Add to your candidate list</a>--></td>
												</tr>
												<tr>
													<td><label class="cv_title_label">Past experience: </label></td>
													<td>
														<?php 
															$pastexp = $candidate->getPastExperience(JRequest::getVar('id'));
															if($pastexp){
																echo "(".$pastexp->employer_position.") <b>".$pastexp->employer."</b>";
															}
														?>
													</td>
													<td><a style ="float:right;" target = "new" href="<?php echo JURI::base(true).'/'.$com_base?>views/candidates/tmpl/candidatepdf.php?id=<?php echo JRequest::getVar('id');?>">Download full CV in PDF</a></td>
												</tr>
											</tbody>
										</table>
								     
                                    </div>
									<!--//Ennd Background-->
									
									<div class="cv-3 job-option-block" style="width:527px;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">Contact Info</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
													<table width="100%">
														<tr>
															<td><label class="cv_title_label">Email: </label></td>
															<td> <?php echo $data->email; ?></td>
														</tr>
														<tr>
															<td><label class="cv_title_label">Tel: </label></td>
															<td> <?php echo $data->phone; ?></td>
														</tr>
														<tr>
															<td><label class="cv_title_label">Address: </label></td>
															<td> <?php echo $data->address; ?></td>
														</tr>
													</table>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
									 <div class="cv-3 job-option-block" style="width:527px;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">Career objective</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
													<?php echo $data->CAREER_OBJECTIVE; ?>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
									 <div class="cv-3 job-option-block" style="width:527px;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">Professional Experience</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
												 <?php 
													if ( $data = $candidate->getProListByResumeId(JRequest::getVar('id')) ) {
													 $n = count($data);
														 
														 for ( $i = 0; $i < $n; $i++) {
																?>
																<div class="divwrapp1"  id="pro_experience_parent_form" style="width:475px;margin:5px 0px;">
																<strong><?php echo $data[$i]->employer_position;?></strong>
																<p><strong class="txt-b1"><?php echo $data[$i]->employer;?></strong></p>
																<div><?php echo $data[$i]->employer_address." | ";?> <?php echo $data[$i]->employer_city." | ";?> <?php echo $candidate->getCountryByCode($data[$i]->employer_country);?></div>
																<div>Tel: <?php echo $data[$i]->employer_phone;?></div>
																<div><?php echo date('M-Y',strtotime($data[$i]->employer_from_date));?> - <?php echo date('M-Y',strtotime($data[$i]->employer_to_date));?> (<?php echo round((abs(strtotime($data[$i]->employer_to_date)-strtotime($data[$i]->employer_from_date))/86400)/30)?> months)</div>		
																<p><strong class="txt-b1"><?php echo $data[$i]->employer_resp;?></strong></p>
																</div>
																<?php
																
														  }
													}
												  
												  ?>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
									 <div class="cv-3 job-option-block" style="width:527px;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">Education/Training</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
												 <?php 
													if ( $data = $candidate->getEducationList(JRequest::getVar('id')) ) {
													 $n = 3;
														 for ( $i = 0; $i <= $n; $i++) {
																if ($i==0) {
																	$sub_fix ='';
																} else {
																	$sub_fix =$i;
																}
															 if($data['institute'.$sub_fix] != ''){
																?>
															<div class="divwrapp1" style="width:475px;margin:5px 0px;">
															<strong><?php echo $data['institute'.$sub_fix];?></strong>
															<div>Certification title: <strong><?php echo $data['institute'.$sub_fix];?></strong> </div>
															<div>
															 Education level: <strong><?php echo $data['institute'.$sub_fix.'_level'];?></strong>  | 
															 Year of degree: <strong><?php echo $data['institute'.$sub_fix.'_certificate_name'];?></strong>  |  
															 Area of study: <strong><?php echo $data['institute'.$sub_fix.'_study_area'];?></strong>  |   
															 Country: <strong><?php echo $candidate->getCountryByCode($data['institute'.$sub_fix.'_country']); ?></strong>
															 </div>
														   
													   </div>     
												   <?php
															 }//End if
														 }
													}
												?>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
									 <div class="cv-3 job-option-block" style="width:527px;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">Skills</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
												<?php 
													if ( $data = $candidate->getSkillsListByResumeId(JRequest::getVar('id')) ) {
													 $n = count($data);
														 for ( $i = 0; $i < $n; $i++) {
																?>
																<div class="divwrapp2">
																	<strong><?php echo $data[$i]->skill_name;?></strong>
																</div>
																<?php
																
														  }
													}
												  
												  ?>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
									 <div class="cv-3 job-option-block" style="width:527px; margin-bottom: 20px; float: left;">
											<div class="job-option-block-header active">
												<h3 class="sub-title">References</h3>
											</div>
										  <div class="job-option-block-content">
										      <!--start content-->
											   <div class="divwrapp">
												  <?php 
													if ( $data = $candidate->getReferenceList(JRequest::getVar('id')) ) {
														 $n = 3;
														 for ( $i = 0; $i <= $n; $i++) {
																$subfix = $i;
																if ( $i == 0 ) {
																	$subfix = '';
																} 
															  if ( $data['reference'.$subfix.'_name'] != '') { 
																  $ref_base_url = "index.php?option=com_wrecruit&c=wrecruit&view=candidates&tas=deletereference&layout=buildcv&Itemid=".JRequest::getVar('Itemid')."&id=".JRequest::getVar('id')."&part=".$data['reference'.$subfix];
															  ?>
																		
																	<div class="divwrapp1" style="width:475px;margin:5px 0px;" id="wrapper_<?php echo $data['reference'.$subfix]; ?>">
																	<strong>Reference name: <?php echo $data['reference'.$subfix]; ?></strong>
																	<div>
																	 Relationship: <strong><?php echo $data['reference'.$subfix.'_relation']; ?></strong>  | 
																	 Year of knowing: <strong><?php echo $data['reference'.$subfix.'_years']; ?></strong>   | 
																	 Phone number: <strong><?php echo $data['reference'.$subfix.'_phone']; ?></strong></div> 
																	<div>Address:  <strong><?php echo $data['reference'.$subfix.'_address']; ?> </strong> | 
																	 City : <strong><?php echo $data['reference'.$subfix.'_city']; ?></strong>   |  
																	Country: <strong><?php echo $candidate->getCountryByCode($data['reference'.$subfix.'_country']); ?></strong></div>
																	
															   </div>
															  <?php }
														 }
														
													}
												   ?>
											   </div>
											   <!--end content-->
										  </div>
										 
									 </div>
					  <?php
						}//end Check type
					  } 
					  ?>			 
                 
					</div>
					
				</div>
				
				<!--<div class="box-banner-bottom">					
					<img src="<?php echo $com_base;?>images/banner-avertise-bottom.jpg" alt="" title="" width="745" height="122" />
				</div>-->
	  <!--popup content-->
        <div id="popupContainer" class="hidden" style="text-align:left;">
            <a id="close" class="hidden" title="close popup"></a>   
            <center>
            <form action="index.php" method="post">
            <table border="0">
            	<tr>
                	<td><input type="text" class="text" value="<?php echo $candidateObj->EMAIL;?>" name="mails" /></td>
                    <td></td>
                </tr>
                <tr>
                	<td colspan="2" align="right"> <input type="submit" value="Save" /></td>
                </tr>
            </table>
            </form>
            </center>
             
        </div>
        <div id="overlayEffect">
        </div>
       <!--end popup content--> 
